const express = require('express')
const data = require('./data/local')

const app = express()

app.get('/top/playlist',(request,response)=>{
    var {offset,limit} = request.query;
    response.setHeader('Access-Control-Allow-Origin','*')
    offset = Number(offset)
    limit = Number(limit)
    if(!offset){
        offset = 0
    }
    if(!limit){
        limit = 5
    }
    var result = data.result
    var obj = {
        code:200,
        data:result.slice(offset,offset+limit),
        total:result.length
    }
    response.send(obj)
})

app.listen(8000,()=>{
    console.log('服务器开启成功');
})